package com.demo.controller;

import com.demo.bean.Comment;
import com.demo.common.Result;
import com.demo.service.CommentService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: lixiaodong
 * @Description:  restfull风格及分页
 * @Date: 2022/9/15 15:19
 * @Parms:
 * @ReturnType:
 */

@Slf4j
@RestController
@Api(tags = "restfull风格及分页")
public class CommentController extends BaseController{
	@Autowired
	CommentService commentService;

	@GetMapping("/comment/{id}")
	public Result findById(@PathVariable(value = "id") Integer id){
		return commentService.findById(id);
	}
	@GetMapping("/commentPage/{pageId}/{pageSize}")
	public Result findPage(@PathVariable(value = "pageId") Integer pageId,
								   @PathVariable(value = "pageSize") Integer pageSize){
		return commentService.findPage(pageId,pageSize);
	}
	@PostMapping("/comment")
	public Result insert(@RequestBody List<Comment> commentList ){
		log.info(commentList.toString());

		return commentService.insert(commentList);
	}
	@PutMapping("/comment")
	public Result update(@RequestBody Comment comment ){
		return commentService.update(comment);
	}
	@DeleteMapping("/comment/{ids}")
	public Result delete(@PathVariable("ids") List<Long> ids ){
		return commentService.delete(ids);
	}

	@GetMapping("/commentVoPage/{pageId}/{pageSize}")
	public Result commentVoPage(@PathVariable(value = "pageId") Integer pageId,
								   @PathVariable(value = "pageSize") Integer pageSize){
		return commentService.commentVoPage(pageId,pageSize);
	}




}
